package LeetCode.exercise;

import java.util.HashMap;
import java.util.Map;

public class LC76 {
    public static void main(String[] args) {

        System.out.println("+========");
    }
        public static String minWindow(String s, String t) {
            int[] arr1 = new int[128];
            int[] arr2 = new int[128];
            int kind = 0;
            for(int i = 0; i < t.length(); i++){
                if(arr1[t.charAt(i)] == 0){
                    kind++;
                }
                arr1[t.charAt(i)]++;
            }
            char[] arr = s.toCharArray();
            int index = -1, minlen = Integer.MAX_VALUE;
            for(int left = 0, right = 0, count = 0; right < arr.length; right++){
                arr2[arr[right]]++;
                if(arr2[arr[right]] == arr1[arr[right]]){
                    count++;
                }
                while(count == kind){
                    if(right - left + 1 < minlen){
                        index = left;
                        minlen = right - left +1;
                    }
                    if(arr1[arr[left]] == arr2[arr[left]]){
                        count--;
                    }
                    arr2[arr[left]]--;
                    left++;
                }
            }
            if(index == -1){
                return "";
            }
            return s.substring(index, index + minlen);
        }
    }
